<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">

    <title>图书管理系统</title>
    <link rel="stylesheet" href="../css/log.css">
    <script src="../js/jquery-3.6.0.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $('#password').focus(function () {
                // 密码框获得焦点，追加样式.password
                $('#owl').addClass('password');
            }).blur(function () {
                // 密码框失去焦点，移除样式.password
                $('#owl').removeClass('password');
            })
        })
    </script>
</head>

<body>
<div class="login-tab" style="color: white">
    <h1>猫头鹰图书管理系统</h1>
</div>
<div class="login-box">
    <div class="owl" id="owl">
        <div class="hand"></div>
        <div class="hand hand-r"></div>
        <div class="arms">
            <div class="arm"></div>
            <div class="arm arm-r"></div>
        </div>
    </div>
    <div v-model="formData" id="app" class="input-box">
        <input id="username" type="text" v-model="formData.username" placeholder="账号">
        <input id="password" type="password" v-model="formData.password" placeholder="密码">
        <div style="visibility: hidden" >x</div>
        <button @click="getUser()">登录</button>
    </div>
    <div class="login-msg" id="login_msg" style="visibility: hidden">
        <div style="text-align: center">
            <div style="color: red">用户名或密码有误请重新输入
            </div>
        </div>
    </div>
    <div class="regiester"><a href="http://localhost/pages/register.html">注册账号</a></div>
    <div class="forgetpassword"><a href="">忘记密码</a></div>
</div>
</body>
<script src="../js/vue.js"></script>
<script src="../js/axios-0.18.0.js"></script>
<script>
    new Vue({
        el: "#app",
        data: {
            formData: {
                username: '',
                password: ''
            },//表单数据
        },
        methods: {
            getUser() {
                axios.post("http://localhost/users",this.formData).then((res) => {
                    if (res.data.code == 801) {
                        document.location.href = "bokks.html"
                    }else {
                        document.getElementById("login_msg").style.visibility="visible"
                        setTimeout(function (){
                            document.getElementById("login_msg").style.visibility="hidden"
                        },3000)
                    }
                });
            }
        }
    })
</script>
</html>

